﻿#include "../../interface/IFont.h"

namespace swui
{
	void IFont::_flush_font_()
	{
		redraw();
	}
	void IFont::_virtual_font_create() 
	{
		_font_index = getFontQueue()->getDefaultIndex();
		setTextAlignMode(textAlign::center);
	}
	ctlPoint IFont::_getTextSize()
	{
		return getFont()->getTextSize(_textpack.wptr(), -1,  true);
	}
	bool IFont::setFont(unsigned index)
	{
		if(index >= getFontQueue()->getQueueSize()) 
			return false;
		_font_index = index;
		_flush_font_();
		return true;
	}
	unsigned IFont::getFontIndex()
	{
		return _font_index;
	}
	std::shared_ptr<ctlFont> IFont::getFont()
	{
		return getFontQueue()->getElement(getFontIndex());
	}
	IFont::textAlign IFont::getTextAlignMode()
	{
		return _font_alignMode;
	}
	 void IFont::setTextAlignMode(IFont::textAlign mode) 
	 {
		_font_alignMode = mode;
		redraw();
	}
}	//namespace swui
